package com.lly.songhigh.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;

import com.lly.songhigh.R;
import com.lly.songhigh.constant.URL;


/**
 * Created by dllo on 15/10/21.
 */
public class ChineseFragment extends BaseFragment implements RadioGroup.OnCheckedChangeListener {
    //定义viewPager对象
    private RadioGroup chinese_sin_tab;
    private FragmentTransaction transaction;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.chinese_fragment, null);
        initViews(view);
        return view;
    }
    private void initViews(View view) {
        chinese_sin_tab  = (RadioGroup) view.findViewById(R.id.chinese_sin_tab);

        // 设置监听
        chinese_sin_tab.setOnCheckedChangeListener(this);
        transaction = getChildFragmentManager().beginTransaction();
        transaction.replace(R.id.tabView1, SingerClassifyFragment.newInstance(URL.CHINESE_MAN)).addToBackStack(null);
        transaction.commit();
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.male_singer:
                transaction = getChildFragmentManager().beginTransaction();
                transaction.replace(R.id.tabView1, SingerClassifyFragment.newInstance(URL.CHINESE_MAN));
                transaction.commit();
                break;
            case R.id.female_singer:
                transaction = getChildFragmentManager().beginTransaction();
                transaction.replace(R.id.tabView1, SingerClassifyFragment.newInstance(URL.CHINESE_WOMEN));
                transaction.commit();
                break;
            case R.id.combination_singer:
                transaction = getChildFragmentManager().beginTransaction();
                transaction.replace(R.id.tabView1, SingerClassifyFragment.newInstance(URL.CHINESE_COMBINATION));
                transaction.commit();
                break;

        }

    }
    @Override
    public void onResume() {
        super.onResume();
    }
}